<template>
  <div>
    <div class="col-lg-6">
      <div class="input-group">
        <input type="text" class="form-control" v-model='name' placeholder="根据姓名查询">
        <span class="input-group-btn">
          <button class="btn btn-default" type="button" @click='search'>查询</button>
        </span>
      </div><!-- /input-group -->
    </div><!-- /.col-lg-6 -->
    <table class="table table-bordered table-hover">
      <thead>
        <tr>
          <th>用户id</th>
          <th>用户名</th>
          <th>邮箱</th>
          <th>家庭住址</th>
        </tr>
      </thead>
      <tbody id="tbody">
        <tr v-for="(data,index) in searchDatas" :key="data.id" :ref="index">
          <td>{{data.id}}</td>
          <td>{{data.name}}</td>
          <td>{{data.email}}</td>
          <td>{{data.address}}</td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script>
export default {
  name: 'Operation',
  data () {
    return {
      name: ''
    }
  },
  props: {
    searchDatas: {
      type: Array
    }
  },
  methods: {
    search () {
      this.$emit('searchData', this.name)
    }
  }
}

</script>
